Skip to content

Conversation

jcking
Copy link
Contributor

@jcking jcking commented Oct 6, 2025

Remove unnecessary release barriers in JavaFrameAnchor::{copy,clear} and fix MacroAssembler::set_last_Java_frame to set sp last as expected by the profiler.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8369190: JavaFrameAnchor on AArch64 has unnecessary barriers and wrong store order in MacroAssembler (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27645/head:pull/27645
$ git checkout pull/27645

Update a local copy of the PR:
$ git checkout pull/27645
$ git pull https://git.openjdk.org/jdk.git pull/27645/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27645

View PR using the GUI difftool:
$ git pr show -t 27645

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27645.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 6, 2025

👋 Welcome back jcking! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 6, 2025

@jcking This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot changed the title JDK-8369190: JavaFrameAnchor on AArch64 appears to be missing barriers 8369190: JavaFrameAnchor on AArch64 appears to be missing barriers Oct 6, 2025
@openjdk
Copy link

openjdk bot commented Oct 6, 2025

@jcking The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 6, 2025
Signed-off-by: Justin King <[email protected]>
@mlbridge
Copy link

mlbridge bot commented Oct 6, 2025

Webrevs

Signed-off-by: Justin King <[email protected]>
@jcking jcking requested a review from theRealAph October 6, 2025 16:21
@jcking jcking changed the title 8369190: JavaFrameAnchor on AArch64 appears to be missing barriers 8369190: JavaFrameAnchor on AArch64 has unnecessary barriers and wrong store order in MacroAssembler Oct 6, 2025
Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Add a comment to the effect that we don't need a fence because the profiler always reads from the same thread, and we're done.

@jcking
Copy link
Contributor Author

jcking commented Oct 6, 2025

Thanks. Add a comment to the effect that we don't need a fence because the profiler always reads from the same thread, and we're done.

Done. Let me know if you had something else in mind where you wanted the comment.

@jcking jcking requested a review from theRealAph October 6, 2025 16:35
Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

Although in the end we don't need a fence, you prompted me to measure the difference between a releasing store (STLR) and a DMB ST; STR and to my surprise STLR is way faster, at least on Apple hardware.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 6, 2025
Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, approval rescinded.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 6, 2025
// unless the value is changing
//
// No fencing required, the members are declared volatile so the compiler will not reorder and
// the profiler always reads from the same thread and should observe the state in program order.
Copy link
Member

@dean-long dean-long Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think copy() is ever called. Can we remove it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think copy() is ever called. Can we remove it?

Sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think copy() is ever called. Can we remove it?

Sure.

Ah no. copy() is called after the anchor is constructed.

@jcking jcking requested review from theRealAph and dean-long October 7, 2025 13:59
Signed-off-by: Justin King <[email protected]>
Comment on lines +99 to +105
// Complier barrier which prevents the compiler from reordering loads and stores.
// It does not prevent the hardware from doing so. Typically you should use
// OrderAccess instead.
static inline void compiler_barrier() {
__asm__ volatile ("" : : : "memory");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this in portable C++ since C++11:

// Complier barrier which prevents the compiler from reordering loads and stores.
static inline void compiler_barrier() {
  std::atomic_signal_fence(memory_order_seq_cst);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some rules about not calling the Standard C++ libraries in the Guidelines, but given that this one only prevents the compiler from moving things around and does not generate any code, I don't think that really applies. More legalisticaily-minded people might disagree, but I prefer portable code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does require including <atomic>, which seems not ideal in globalDefinitions. Additionally <atomic> will likely eventually include <stdatomic.h> which defines memory_order as well. So I think we will have to live with what is currently here.

@jcking jcking requested a review from theRealAph October 7, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants